package com.tengju.settlement.domain.model.depository;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum DepositoryChannel {

    PING_AN(1,2,"平安见证宝"),
    INTERNAL(2,0,"内部户"),

    ;

    Integer innerVal;
    Integer abmVal;
    String desc;

    @JsonValue
    public Integer getInnerVal() {
        return innerVal;
    }

    @JsonCreator
    public static DepositoryChannel ofInnerCode(Integer innerCode) {
        for (DepositoryChannel channel : values()) {
            if (channel.innerVal.equals(innerCode)) {
                return channel;
            }
        }
        return null;
    }

    public static DepositoryChannel ofAbmCode(Integer abmCode) {
        for (DepositoryChannel channel : values()) {
            if (channel.abmVal.equals(abmCode)) {
                return channel;
            }
        }
        return null;
    }

}
